﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace plust.Content
{
    public class PagoViewModel : INotifyPropertyChanged, IDataErrorInfo
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private string tipo;
        private string monto;
        private string descripcion;

        public string Tipo
        {
            get { return this.tipo; }
            set
            {
                this.tipo = value;
                OnPropertyChanged("Tipo");
            }
        }

        public string Monto
        {
            get { return this.monto; }
            set
            {
                this.monto = value;
                OnPropertyChanged("Monto");
            }
        }

        public string Descripcion
        {
            get { return this.descripcion; }
            set
            {
                this.descripcion = value;
                OnPropertyChanged("Descripcion");
            }
        }

        public string this[string columnName]
        {
            get
            {
                if (columnName == "Tipo")
                {
                    return string.IsNullOrEmpty(this.tipo) ? "Valor Requerido" : null;
                }

                if (columnName == "Monto")
                {
                    return string.IsNullOrEmpty(this.monto) ? "Valor Requerido" : null;
                }

                if (columnName == "Descripcion")
                {
                    return string.IsNullOrEmpty(this.descripcion) ? "Valor Requerido" : null;
                }

                return null;
            }
        }

        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }

        public string Error
        {
            get { return null; }
        }
    }
}
